<template>
    <div>
        <el-card class="box-card" shadow="never">
            <!--导航栏-->
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item>系统设置</el-breadcrumb-item>
                <el-breadcrumb-item>用户列表</el-breadcrumb-item>
            </el-breadcrumb>
            <!--分割线-->
            <div class="yx_line"></div>
            <el-row :gutter="10" style="margin-top:20px;">
               <el-col :span='6'>
                  <el-input v-model="nickname">
                    <template slot="prepend">昵称</template>
                  </el-input>
               </el-col>
            </el-row>
            <el-row class="yx_el_row">
                <el-col>
                    <el-button type="success" plain @click="search">筛选</el-button>
                </el-col>
            </el-row>
            <el-table class="yx_table" border :data="userlist">
                <el-table-column prop="index" label="序号" width="100">
                </el-table-column>
                <el-table-column prop="avatar_url" label="头像" width="180">
                    <template slot-scope="scope">
                          <el-avatar :size="50" :src="scope.row.avatar_url"></el-avatar>
                    </template>
                </el-table-column>
                <el-table-column prop="nickname" label="昵称" width="180">
                </el-table-column>
                <el-table-column prop="gender" label="性别" width="150">
                </el-table-column>
                <el-table-column prop="area" label="地区" width="150">
                </el-table-column>
                <el-table-column prop="phone" label="手机号" width="150">
                </el-table-column>
                <el-table-column prop="create_time" label="加入时间">
                </el-table-column>

            </el-table>
            <Pagination :total_count="total_count" :getList="getList"></Pagination>
        </el-card>
    </div>
</template>

<script>
    import Pagination from '@/components/Pagination.vue';
    import { getUserList } from '@/api/user.js';
    export default {
        name: 'UserList',
        inject:['reload'],
        components:{ Pagination },
        data() {
            return {
                userlist:[],
                total_count:0,
                nickname:'',
            }
        },
        methods: {
            getList(current_page,page_size){
                var send_data={
                    api_token:this.$store.getters.getSessionId,
                    current_page:current_page,
                    page_size:page_size,
                    nickname:this.nickname,
                }
                let that=this;
                getUserList(send_data).then(function(response){
                   if(response.data.code==1){
                     that.userlist=response.data.list;
                     that.total_count=response.data.total_count;
                   }
                })
            },
            search(){
               this.getList(1,this.$store.state.default_page_size);
            },
        },
        created() {
            //加载列表
            this.getList(1,this.$store.state.default_page_size);
        }
    }
</script>

<style>
     @import url('../../assets/css/table.css');
</style>
